package main

import (
	"flag"
	"fmt"
	"serverlog/global"
	"serverlog/src"
)

var (
	h        bool
	confPath string
)

func init() {
	flag.BoolVar(&h, "h", false, "帮助")
	flag.StringVar(&confPath, "c", ".", "配置文件目录")

	flag.Usage = usage
}

func usage() {
	fmt.Println("Usage: server [-h] [-c] conf_dir\nOptions:\n")
	flag.PrintDefaults()
}

func main() {
	flag.Parse()
	if h {
		flag.Usage()
	}
	global.ServerGlobal.Init(confPath)
	s := serverlog.NewServer(global.ServerGlobal.Port)
	s.Run()
}
